package com.yunkont.pigcontrol.app;

import android.app.Application;

import com.yunkont.pigcontrol.bean.AllPigBean;
import com.zhy.http.okhttp.OkHttpUtils;

import java.util.concurrent.TimeUnit;

import okhttp3.OkHttpClient;

/**
 * Created by ZJB on 2017/9/21.
 *
 * @ copyright: iwhere chengdu technology
 */

public class BaseApplicaiton extends Application{
    private static BaseApplicaiton applicaiton;
    private AllPigBean allPigBean;
//    private AllPigBean.EmbeddedBean.PigConfigsBean currentPigBean;
    private String currentPid;
    private String linkUrl;



    @Override
    public void onCreate() {
        super.onCreate();
        okInit();
        applicaiton = this;
        initOkHttp();
    }

    private void initOkHttp(){
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
//                .addInterceptor(new LoggerInterceptor("TAG"))
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                //其他配置
                .build();

        OkHttpUtils.initClient(okHttpClient);
    }

    private void okInit(){
        OkHttpClient okHttpClient = new OkHttpClient.Builder()
                .connectTimeout(10000L, TimeUnit.MILLISECONDS)
                .readTimeout(10000L, TimeUnit.MILLISECONDS)
                //其他配置
                .build();
        OkHttpUtils.initClient(okHttpClient);
    }

    public static BaseApplicaiton getInstance(){
        return applicaiton;
    }

    public AllPigBean getAllPigBean() {
        return allPigBean;
    }
    public void setAllPigBean(AllPigBean allPigBean) {
        this.allPigBean = allPigBean;
    }

    public String getCurrentPid() {
        return currentPid;
    }

    public void setCurrentPid(String currentPid) {
        this.currentPid = currentPid;
    }

//    public AllPigBean.EmbeddedBean.PigConfigsBean getCurrentPigBean() {
//        return currentPigBean;
//    }
//
//    public void setCurrentPigBean(AllPigBean.EmbeddedBean.PigConfigsBean currentPigBean) {
//        this.currentPigBean = currentPigBean;
//    }

    public String getLinkUrl() {
        return linkUrl;
    }

    public void setLinkUrl(String linkUrl) {
        this.linkUrl = linkUrl;
    }
}
